import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description: 调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
 *              如数组：[1,2,3,4,5,6]
 *              调整后可能是：[1, 5, 3, 4, 2, 6]
 * User: 15085202591
 * Date: 2022-11-05
 * Time: 10:00
 */
public class ChangeOrder {
    public static int[] change(int[] array){
        int[] newarray = new int[array.length];
        int k = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] % 2 == 1){
                newarray[k] = array[i];
                k++;
            }
        }
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 == 0){
                newarray[k] = array[i];
                k++;
            }
        }
        array = Arrays.copyOf(newarray,array.length);
        return array;
    }
    public static void main(String[] args) {
        int[] array = new int[]{1,2,3,4,5,6};
        System.out.println(Arrays.toString(array));
        array = change(array);
        System.out.println(Arrays.toString(array));
    }
}
